#!/bin/bash
set -e

if [ "$PHPSESSION_SAVE_HANDLER" != "" ]; then
	/bin/sed -i "s~session\.save_handler.*$~session.save_handler=$PHPSESSION_SAVE_HANDLER~g" /etc/php/7.3/fpm/php.ini
fi

if [ "$PHPSESSION_SAVE_HANDLER" != "" ]; then
	/bin/sed -i "s~session\.save_path.*$~session.save_path=\"$PHPSESSION_SAVE_PATH\"~g" /etc/php/7.3/fpm/php.ini
fi

/usr/sbin/cron
service php7.3-fpm start

case ${1} in
  nginx)
    /usr/sbin/nginx
    ;;
  help)
    echo "Available options:"
    echo " nginx            - Starts nginx (default)"
    echo " help             - Displays the help"
    echo " [command]        - Execute the specified command, eg. bash."
    ;;
  *)
    exec "$@"
    ;;
esac

